Character literal
● represents character data type and value where value is 16-bit Unicode character
● is constructed by enclosing character or escape sequence inside single quotes
Escape sequence
● can represent any character, including special ones, as shown by the table below
● starts with backslash / escape character followed by specific combinations representing a character
Using octal or Unicode character representations is equivalent to typing that character inside your source code.
This differs from escape sequences \n, \' or \" which will not throw error while '\u000D', '\u0027' or '\u0022' might.
Character
//BASIC CHARACTER LITERAL.
char mark = 'A'; //'A' character.
mark = '\t'; //Tab character.
mark = '\"'; //Double quote character.
mark = '\''; //Single quote character.
//USING OCTAL ESCAPE SEQUENCE.
char mark = '\101'; //'A' character.
mark = '\10'; //Tab quote character.
mark = '\42'; //Double quote character.
mark = '\47'; //Single quote character.
//USING UNICODE ESCAPE SEQUENCE. USES HEXADECIMAL ASCII VALUES WITH LEADING ZEROS.
char mark = '\u0041'; //'A' character.
mark = '\u0009'; //Tab character
mark = '\u0022'; //Double quote character
mark = '\u0027'; //Single quote character reports error.